#define D2D_INPUT_COUNT 1
#define D2D_INPUT0_COMPLEX
#include "d2d1effecthelpers.hlsli"

float t =0;
int model =0;
D2D_PS_ENTRY(main){
    //获取当前像素在屏幕上的位置（相对位置）
    float2 pos =D2DGetInputCoordinate(0);
    float x =pos.x;
    float y =pos.y;
    float time = t*0.5;
   //0左右开门,1左右推开门
    if(model<2){
         if(abs(x-0.5)<time)
            return float4(0,0,0,0);
        float dir =x<0.5?1:-1;
        x = x+  (step(1,model) * (time*dir));
    }
    //2上下开没,3上下推开门
    else if(model<4){
        if(abs(y-0.5)<time)
            return float4(0,0,0,0);
        float dir = y<0.5?1:-1;
        y =y +  (step(3,model) * (time*dir));
    }
    //4左右关门，5左右推关门
    else if(model<6){
          if(0.5-time>abs(x-0.5))
            return float4(0,0,0,0);
        float dir =x<0.5?1:-1;
        x = x+ (step(5,model) * ((0.5-time)*dir));
    }
    //6上下关门，7上下推关门
    else if(model<8){
          if(0.5-time>abs(y-0.5))
            return float4(0,0,0,0);
        float dir =y<0.5?1:-1;
        y = y+ (step(7,model) * ((0.5-time)*dir));
    }
    
    //按百分比进行采样
    return D2DSampleInput(0,float2(x,y));
}

// set INCLUDEPATH="%WindowsSdkDir%\Include\%WindowsSDKVersion%\um"
//  fxc OpenDoorLeftAndRight.hlsl /nologo /T lib_4_0_ps_only /D D2D_FUNCTION /D D2D_ENTRY=main /Fl OpenDoorLeftAndRight.fxlib /I %INCLUDEPATH%
//  fxc OpenDoorLeftAndRight.hlsl /nologo /T ps_4_0 /D D2D_FULL_SHADER /D D2D_ENTRY=main /E main /setprivate OpenDoorLeftAndRight.fxlib /Fo:OpenDoorLeftAndRight.bin /I %INCLUDEPATH%
// del OpenDoorLeftAndRight.fxlib